<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "tbl_form_option".
 *
 * @property integer $id
 * @property string $title
 * @property integer $isshow
 * @property integer $paixu
 */
class FormOption extends \yii\db\ActiveRecord
{
    
    /**
     * 根据id返回标题
    */
    public static function getTitle($id){
        $lab=self::getLabels();
        if(isset($lab[$id])){
            return $lab[$id];
        }else{
            return '未知属性';
        }
    }
    
    static $_allLabels=false;


    /**
     * 获取所有的属性和标题
    */
    public static function getLabels(){      
        if(self::$_allLabels){
            return self::$_allLabels;
        }
        self::$_allLabels=[]; 
        $all=self::find()->all();
        foreach ($all as $vo){
            self::$_allLabels[$vo->id]=$vo['title'];
        }
        return self::$_allLabels;
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'tbl_form_option';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['isshow'], 'integer'],
            [['title'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => 'Title',
            'isshow' => 'Isshow',
            'paixu'=>'排序'
        ];
    }
}
